package com.zlm.controller;

import com.zlm.constants.SysConstants;
import com.zlm.domain.ResponseResult;
import com.zlm.domain.entity.Comment;
import com.zlm.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zlm
 * @date 2024/12/10
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 文章评论列表
     * @param articleId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("commentList")
    public ResponseResult commentList(Long articleId, Integer pageNum, Integer pageSize){
        return commentService.commentList(SysConstants.ARTICLE_COMMENT_TYPE,articleId,pageNum,pageSize);
    }

    @PostMapping
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
    @GetMapping("/linkCommentList")
    public ResponseResult linkCommentList(Integer pageNum, Integer pageSize){

        return commentService.commentList(SysConstants.LINK_COMMENT_TYPE,null,pageNum,pageSize);
    }
}
